package spring.cloud.jacquesh.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import spring.cloud.jacquesh.service.PaymentHystrixService;

import javax.annotation.Resource;

@RestController
public class OrderHyrixController {
    @Resource
 private PaymentHystrixService paymentHystrixService;
    @GetMapping("/consumer/hystrix/ok/{id}")
    String paymentInfo_OK(@PathVariable("id") Integer id){
        return  paymentHystrixService.paymentInfo_OK(id);
    }

    /**
     * 超时访问
     *
     * @param id
     * @return
     */
    @GetMapping("/consumer/hystrix/timeout/{id}")
//    @HystrixCommand(fallbackMethod = "paymentTimeOutFallbackMethod", commandProperties = {
//            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1500")
//    })
    String paymentInfo_TimeOut(@PathVariable("id") Integer id){
        return  paymentHystrixService.paymentInfo_TimeOut(id);
    }
//    public String paymentTimeOutFallbackMethod(@PathVariable("id") Integer id) {
//        return "我是消费者80,对方支付系统繁忙请10秒种后再试或者自己运行出错请检查自己,o(╥﹏╥)o";
//    }
}
